package practice08;

public class Student extends Person{
    //再写一个Student类继承Person类，除了id，name，age属性，还有要有Klass属性。也有一个introduce方法，
    //introduce方法返回一个字符串形如：
    //>My name is Tom. I am 21 years old. I am a Student. I am at Class 2.
    Klass klass;
    public Klass getKlass() {
        return klass;
    }

    public void setKlass(Klass klass) {
        this.klass = klass;
    }

    public Student(Integer id, String name, Integer age, Klass klass) {
        super(id,name,age);
        this.klass=klass;
    }

    private boolean isClassLeader() {
        Student classLeader =  klass.getLeader();
        return this.equals(classLeader);
    }
//    public String introduce() {
//        return this.isClassLeader()? super.introduce()+" I am a Student. I am Leader of Class "+this.getKlass().getDisplayName()+".": super.introduce()+" I am a Student. I am at Class "+this.getKlass().getDisplayName()+".";
//    }
     @Override
     public String introduce() {
        String words = super.introduce() + " I am a Student.";
        words += this.isClassLeader() ? String.format(" I am Leader of %s.", this.getKlass().getDisplayName()) : String.format(" I am at %s.", this.getKlass().getDisplayName());
        return words;
}

}
